// pages/index/orderList/orderList.js
const utils = require('../../../utils/utils.js')

Page({

  /**
   * 页面的初始数据
   */
  data: {
    isSearchShow: false,  // 搜索框是否展示

    contentValue: 0,
    contentOption: [
      { text: '订单名称', value: 0 },
      { text: '客户名称', value: 1 },
      { text: '合同编号', value: 2 },
    ],
    contentInput: '',

    timeValue: 0,
    timeOption: [
      { text: '上刊时间', value: 0 },
      { text: '下刊时间', value: 1 },
      { text: '创建时间', value: 2 },
    ],

    pageStartDate: '',
    pageEndDate: '',
    
    isStartDateShow: false,
    isEndDateShow: false,
    pickerStartDate: new Date().getTime(),
    pickerEndDate: new Date().getTime(),

    cityValue: 0,
    cityOption: [
      { text: '长春市', value: 0 },
    ],

    statusValue: 0,
    statusOption: [
      { text: '未上刊', value: 0 },
      { text: '已上刊', value: 1 },
      { text: '已下刊', value: 2 },
      { text: '已完成', value: 3 },
      { text: '强制结束', value: 3 },
    ],

    pageLaunchDate: '',
    isLaunchDateShow: false,
    pickerLaunchDate: new Date().getTime(),


  },

  showSearch() {
    // this.setData({ isSearchShow: true });
  },

  closeSearch() {
    this.setData({ isSearchShow: false });
  },

  showStartDate() {
    this.setData({ isStartDateShow: true });
  },
  
  closeStartDate() {
    this.setData({ isStartDateShow: false });
  },

  changeStartDate(e) {
    console.log(e);
    let date = e.detail
    // console.log(utils.formatDate(date));
    this.setData({
      pageStartDate: utils.formatDate(date)
    })
    this.closeStartDate();
  },
  
  showEndDate() {
    this.setData({ isEndDateShow: true });
  },
  
  closeEndDate() {
    this.setData({ isEndDateShow: false });
  },

  changeEndDate(e) {
    console.log(e);
    let date = e.detail
    this.setData({
      pageEndDate: utils.formatDate(date)
    })
    this.closeEndDate();
  },

  showLaunchDate() {
    this.setData({ isLaunchDateShow: true });
  },
  
  closeLaunchDate() {
    this.setData({ isLaunchDateShow: false });
  },

  changeLaunchDate(e) {
    console.log(e);
    let date = e.detail
    this.setData({
      pageLaunchDate: utils.formatDate(date)
    })
    this.closeLaunchDate();
  },

  goOrderUpload() {
    wx.navigateTo({
      url: '/pages/index/orderUpload/orderUpload',
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.hideShareMenu();
    wx.setNavigationBarTitle({
      title: '订单管理' 
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})